/**
 * Copyright 2017 JINZAY All Rights Reserved.
 */
package com.qingfeng.manager;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @description: 配置类{@EnableWebMvc：springMVC、@MapperScan：Mybatis扫描mapper接口、@ComponentScan：spring扫描注解}
 * @author:LWY
 * @date: 2017/10/12 13:28
 * @modified:
 */
/*@EnableWebMvc*/
@Configuration
@ComponentScan({"com.qingfeng.*"})
@MapperScan(basePackages = {"com.qingfeng.core.mapper", "com.qingfeng.core.mapper.qingfeng"})
public class MainConfig {

    @Bean
    public Converter<String, Date> converter() {
        return new Converter<String, Date>() {
            @Override
            public Date convert(String param) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                Date date = null;
                try {
                    date = sdf.parse(param);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return date;
            }
        };
    }
}
